package com.zmn.plat.admin.controller.part.category.first;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.zmn.common.dictionary.GlobalDict;
import com.zmn.plat.admin.controller.part.PartBaseController;
import com.zmn.plat.model.entity.part.PartCategory;
import com.zmn.plat.model.entity.part.PartCategoryQuery;

/**
 * @Auther: admin
 * @since: 2018/10/16 11:23
 * @Description:
 */

@Controller
@RequestMapping("/part/category/first")
public class PartCategoryFirstListController extends PartBaseController {

    private Logger logger = LoggerFactory.getLogger(PartCategoryFirstListController.class);

    /**
     * 描述: [跳转] 跳转到配件分类列表
     *
     * @author DaiZhichao
     * @since 2018/11/6 20:54
     */
    @RequestMapping("/list")
    @RequiresPermissions("/part/category/first/list.action")
    public String partCategoryList(Model model, @ModelAttribute PartCategoryQuery query) {
        model.addAttribute("statuses", GlobalDict.getStatusList(false));

        return "part/category/first/list";
    }

    /**
     * 描述: [跳转] 跳转到配件分类详情（添加/修改）
     *
     * @author DaiZhichao
     * @since 2018/11/6 20:54
     */
    @RequestMapping("/addEdit")
    @RequiresPermissions("/part/category/first/addEdit.action")
    public String detail(@RequestParam(value = "categId", defaultValue = "0") int categId, Model model) {
        PartCategory partCategory = categId != 0 ? partCategoryService.findByKey(categId) : new PartCategory();
        model.addAttribute("partCategory", partCategory);
        model.addAttribute("statuses", GlobalDict.getStatusList(false));
        return "part/category/first/addedit";
    }

}
